

08000892  4911 ldr r1, [$080008d8] (=$020007cc)
08000894  2002 mov r0, #0x2
08000896  6008 str r0, [r1, #0x0]
08000898  4910 ldr r1, [$080008dc] (=$020007d4)
0800089a  2007 mov r0, #0x7
0800089c  6008 str r0, [r1, #0x0]
0800089e  4910 ldr r1, [$080008e0] (=$020007c4)
080008a0  2080 mov r0, #0x80
080008a2  0180 lsl r0, r0, #0x06
080008a4  6008 str r0, [r1, #0x0]
080008a6  f012 bl $080137a0				; EnableFlash();
080008aa  480e ldr r0, [$080008e4] (=$08014810)		; " Current Game %s"
080008ac  4909 ldr r1, [$080008d4] (=$02000830)		; GAMENAME
080008ae  f00c bl $0800d058				; printf();
080008b2  f012 bl $0801380c				; ReadSwitch();
080008b6  2800 cmp r0, #0x0
080008b8  d020 beq $080008fc
080008ba  480b ldr r0, [$080008e8] (=$08014824)		; "  Switch is to the RIGHT"
080008bc  f00c bl $0800d058				; printf();
080008c0  f012 bl $08013828				; ReadButton();
080008c4  2800 cmp r0, #0x0
080008c6  d013 beq $080008f0
080008c8  4808 ldr r0, [$080008ec] (=$08014840)		; "   The BUTTON is PRESSED    "
080008ca  f00c bl $0800d058				; printf();
080008ce  e01b b $08000908

080008f0  4801 ldr r0, [$080008f8] (=$08014860)		; " The BUTTON is NOT PRESSED"
080008f2  f00c bl $0800d058				; printf();
080008f6  e007 b $08000908

080008fc  480b ldr r0, [$0800092c] (=$08014880)		; "   Switch is to the LEFT     "
080008fe  f00c bl $0800d058				; printf();
08000902  480b ldr r0, [$08000930] (=$080148a0)		; "    Button NOT Readable      "
08000904  f00c bl $0800d058				; printf();

08000908  f012 bl $08013304				; TestUSB();
0800090c  1c04 add r4, r0, #0x0
0800090e  4809 ldr r0, [$08000934] (=$080148c0)		; "  Waiting For USB Command   "
08000910  f00c bl $0800d058				; printf();
08000914  2d00 cmp r5, #0x0
08000916  d0bc beq $08000892
08000918  2c02 cmp r4, #0x2
0800091a  d0ba beq $08000892
0800091c  2500 mov r5, #0x0
0800091e  2c00 cmp r4, #0x0
08000920  d00c beq $0800093c
08000922  4805 ldr r0, [$08000938] (=$080148e0)		; "        USB Working    "
08000924  f00c bl $0800d058				; printf();
08000928  e7b3 b $08000892

0800093c  4801 ldr r0, [$08000944] (=$080148f8)		; "         USB ERROR     "
0800093e  f00c bl $0800d058				; printf();
08000942  e7a6 b $08000892



TestUSB() {
08013304  b510 push {r4,lr}
08013306  f000 bl $08013348				; CheckUSBReady();
0801330a  2800 cmp r0, #0x0
0801330c  d101 bne $08013312
0801330e  2002 mov r0, #0x2
08013310  e017 b $08013342
08013312  4c0a ldr r4, [$0801333c] (=$02000860)
08013314  1c20 add r0, r4, #0x0
08013316  f000 bl $08013368				; ReadUSB();
0801331a  1c20 add r0, r4, #0x0
0801331c  f000 bl $080133e0				; WriteUSB();
08013320  7820 ldrb r0, [r4, #0x0]
08013322  2843 cmp r0, #0x43
08013324  d10c bne $08013340
08013326  7860 ldrb r0, [r4, #0x1]
08013328  2842 cmp r0, #0x42
0801332a  d109 bne $08013340
0801332c  78a0 ldrb r0, [r4, #0x2]
0801332e  2857 cmp r0, #0x57
08013330  d106 bne $08013340
08013332  78e4 ldrb r4, [r4, #0x3]
08013334  2cf0 cmp r4, #0xf0
08013336  d103 bne $08013340
08013338  2001 mov r0, #0x1
0801333a  e002 b $08013342

08013340  2000 mov r0, #0x0
08013342  bc10 pop {r4}
08013344  bc02 pop {r1}
08013346  4708 bx r1
}

CheckUSBReady() {
08013348  4802 ldr r0, [$08013354] (=$09fe01c0)
0801334a  8800 ldrh r0, [r0, #0x0]
0801334c  0a00 lsr r0, r0, #0x08
0801334e  2101 mov r1, #0x1
08013350  4008 and r0, r1
08013352  4770 bx lr
}

ReadUSB() {
08013368  b5f0 push {r4-r7,lr}
0801336a  4647 mov r7, r8
0801336c  b480 push {r7}
0801336e  1c02 add r2, r0, #0x0
08013370  2300 mov r3, #0x0
08013372  4d19 ldr r5, [$080133d8] (=$09fe01c0)
08013374  2080 mov r0, #0x80
08013376  0040 lsl r0, r0, #0x01
08013378  4680 mov r8, r0
0801337a  4684 mov r12, r0
0801337c  4f17 ldr r7, [$080133dc] (=$09fe01e0)
0801337e  8829 ldrh r1, [r5, #0x0]
08013380  4660 mov r0, r12
08013382  4008 and r0, r1
08013384  1c5e add r6, r3, #0x1
08013386  2800 cmp r0, #0x0
08013388  d107 bne $0801339a
0801338a  4b13 ldr r3, [$080133d8] (=$09fe01c0)
0801338c  2480 mov r4, #0x80
0801338e  0064 lsl r4, r4, #0x01
08013390  8819 ldrh r1, [r3, #0x0]
08013392  1c20 add r0, r4, #0x0
08013394  4008 and r0, r1
08013396  2800 cmp r0, #0x0
08013398  d0fa beq $08013390
0801339a  8828 ldrh r0, [r5, #0x0]
0801339c  7010 strb r0, [r2, #0x0]
0801339e  3201 add r2, #0x1
080133a0  4640 mov r0, r8
080133a2  8038 strh r0, [r7, #0x0]
080133a4  8829 ldrh r1, [r5, #0x0]
080133a6  4660 mov r0, r12
080133a8  4008 and r0, r1
080133aa  2800 cmp r0, #0x0
080133ac  d007 beq $080133be
080133ae  4b0a ldr r3, [$080133d8] (=$09fe01c0)
080133b0  2480 mov r4, #0x80
080133b2  0064 lsl r4, r4, #0x01
080133b4  8819 ldrh r1, [r3, #0x0]
080133b6  1c20 add r0, r4, #0x0
080133b8  4008 and r0, r1
080133ba  2800 cmp r0, #0x0
080133bc  d1fa bne $080133b4
080133be  8828 ldrh r0, [r5, #0x0]
080133c0  7010 strb r0, [r2, #0x0]
080133c2  3201 add r2, #0x1
080133c4  2000 mov r0, #0x0
080133c6  8038 strh r0, [r7, #0x0]
080133c8  1c33 add r3, r6, #0x0
080133ca  2b03 cmp r3, #0x3
080133cc  ddd7 ble $0801337e
080133ce  bc08 pop {r3}
080133d0  4698 mov r8, r3
080133d2  bcf0 pop {r4-r7}
080133d4  bc01 pop {r0}
080133d6  4700 bx r0
}

WriteUSB() {
080133e0  b5f0 push {r4-r7,lr}
080133e2  4647 mov r7, r8
080133e4  b480 push {r7}
080133e6  1c02 add r2, r0, #0x0
080133e8  2300 mov r3, #0x0
080133ea  481c ldr r0, [$0801345c] (=$09fe01c0)
080133ec  4684 mov r12, r0
080133ee  2080 mov r0, #0x80
080133f0  0040 lsl r0, r0, #0x01
080133f2  1c07 add r7, r0, #0x0
080133f4  4680 mov r8, r0
080133f6  4d1a ldr r5, [$08013460] (=$09fe01e0)
080133f8  4660 mov r0, r12
080133fa  8801 ldrh r1, [r0, #0x0]
080133fc  4640 mov r0, r8
080133fe  4008 and r0, r1
08013400  1c5e add r6, r3, #0x1
08013402  2800 cmp r0, #0x0
08013404  d107 bne $08013416
08013406  4b15 ldr r3, [$0801345c] (=$09fe01c0)
08013408  2480 mov r4, #0x80
0801340a  0064 lsl r4, r4, #0x01
0801340c  8819 ldrh r1, [r3, #0x0]
0801340e  1c20 add r0, r4, #0x0
08013410  4008 and r0, r1
08013412  2800 cmp r0, #0x0
08013414  d0fa beq $0801340c
08013416  7810 ldrb r0, [r2, #0x0]
08013418  8028 strh r0, [r5, #0x0]
0801341a  7810 ldrb r0, [r2, #0x0]
0801341c  4338 orr r0, r7
0801341e  8028 strh r0, [r5, #0x0]
08013420  3201 add r2, #0x1
08013422  4660 mov r0, r12
08013424  8801 ldrh r1, [r0, #0x0]
08013426  4640 mov r0, r8
08013428  4008 and r0, r1
0801342a  2800 cmp r0, #0x0
0801342c  d007 beq $0801343e
0801342e  4b0b ldr r3, [$0801345c] (=$09fe01c0)
08013430  2480 mov r4, #0x80
08013432  0064 lsl r4, r4, #0x01
08013434  8819 ldrh r1, [r3, #0x0]
08013436  1c20 add r0, r4, #0x0
08013438  4008 and r0, r1
0801343a  2800 cmp r0, #0x0
0801343c  d1fa bne $08013434
0801343e  7810 ldrb r0, [r2, #0x0]
08013440  4338 orr r0, r7
08013442  8028 strh r0, [r5, #0x0]
08013444  7810 ldrb r0, [r2, #0x0]
08013446  8028 strh r0, [r5, #0x0]
08013448  3201 add r2, #0x1
0801344a  1c33 add r3, r6, #0x0
0801344c  2b03 cmp r3, #0x3
0801344e  ddd3 ble $080133f8
08013450  bc08 pop {r3}
08013452  4698 mov r8, r3
08013454  bcf0 pop {r4-r7}
08013456  bc01 pop {r0}
08013458  4700 bx r0
}
